import axios from 'axios'

//请求拦截器,给所有的请求加上token
axios.interceptors.request.use(function(config){
    //取出localStoasge中存储的token值
    let token = localStorage.getItem('mytoken')
    //设置请求头中Authorization这个名字是后台规定的
    config.headers['Authorization'] = token
    return config
},function (error) {
    return Promise.reject(error)
})

//登录验证
export const checkUser = params =>{
    return axios.post('login',params).then(res =>res.data)
}

//获取用户列表
export const getUserList = params =>{
    return axios.get('users',params).then(res =>res.data)
}
